public class CommonUtils 
{
    public static void SendErrorNotification(Exception e)
    {
        SendErrorNotification(e, null);
    }
    public static void SendErrorNotification(Exception e, String additionalInformation)
    {
        string message;
        
        if(e.getTypeName() == 'DMLException')
        {
            for(Integer i = 0; i < e.getNumDml(); i++)
                message = i + ': ' + e.getDmlMessage(i) + '\r\n';
        }
        else
        {
            message = 'Exception Type:' +  e.getTypeName() + '\r\n\r\nException: ' + e.getMessage();
        }       

        if(null != additionalInformation)
        {
            message = 'Additional Information: ' + additionalInformation + '\r\n\r\n' + message;
        }
        System.Debug(message);
        
        // Send an email to the Apex job's submitter on failure.           
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();           
        String[] toAddresses = new String[] {'SalesforceDev@attinteractive.com'};            
        mail.setToAddresses(toAddresses);                    
        mail.setSubject('Unhandled Apex error in Salesforce. User:' + UserInfo.getUserName());            
        mail.setPlainTextBody('The following exception occurrred:\r\n' + message);            
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
    }
}